package a.f.n;

import a.c.a;
import a.c.ab;
import a.c.d;
import a.c.e;
import a.c.m;
import a.c.x;
import a.c.y;
import a.c.z;
import a.f.mb;
import a.f.o;
import a.f.wc;
import a.f.zc;

import java.util.Comparator;

class f
  extends mb
{
  private static final boolean w = false;
  private cb x;
  private o y;
  private double z = 20.0D;
  private double A = 40.0D;
  private Comparator B = new kb();
  private x C;
  private int D = 0;
  private int E = 0;
  public static final int F = 0;
  public static final int G = 1;
  public static final int H = 2;
  public static final int I = 0;
  public static final int J = 1;
  
  public void a(Comparator paramComparator)
  {
    this.B = paramComparator;
  }
  
  public Comparator a()
  {
    return this.B;
  }
  
  public void a(int paramInt)
  {
    this.E = paramInt;
  }
  
  public int s()
  {
    return this.E;
  }
  
  public void b(int paramInt)
  {
    this.D = paramInt;
  }
  
  public int t()
  {
    return this.D;
  }
  
  public void a(double paramDouble)
  {
    this.z = paramDouble;
  }
  
  public double u()
  {
    return this.z;
  }
  
  public void b(double paramDouble)
  {
    this.A = paramDouble;
  }
  
  public double v()
  {
    return this.A;
  }
  
  public boolean b(o paramo)
  {
    return a.a.kb.e(paramo);
  }
  
  public void a(o paramo)
  {
    boolean bool2 = k.n;
    boolean bool1 = k.m;
    if (!b(paramo)) {
      throw new a("Graph is not a tree");
    }
    ab localab = a.a.kb.i(paramo);
    this.y = paramo;
    this.x = new cb(paramo);
    wc.a(paramo);
    this.C = paramo.B();
    Object localObject;
    if (!bool2) {
      if (!paramo.n())
      {
        w();
        localObject = this.x.a();
        b((e)localObject);
        d(this.x);
        a(this.x);
      }
    }
    do
    {
      if (localab.isEmpty()) {
        break;
      }
      localObject = localab.o();
      wc.a(paramo.b((d)localObject));
      paramo.e((d)localObject);
      if ((!bool2) && (bool1)) {
        return;
      }
    } while (!bool1);
    if (!bool2) {
      paramo.a(this.C);
    }
  }
  
  private void w()
  {
    boolean bool2 = k.n;
    boolean bool1 = k.m;
    if ((bool2) || (this.B != null))
    {
      a.c.w localw = this.y.v();
      do
      {
        if (!localw.e()) {
          break;
        }
        localw.d().b(this.B);
        localw.f();
      } while (!bool1);
    }
  }
  
  private void a(double[] paramArrayOfDouble, int paramInt, e parame)
  {
    boolean bool2 = k.n;
    boolean bool1 = k.m;
    paramArrayOfDouble[paramInt] = Math.max(paramArrayOfDouble[paramInt], this.y.t(parame));
    a.c.w localw = parame.q();
    do
    {
      while (!bool1)
      {
        if (!localw.e()) {
          break;
        }
        a(paramArrayOfDouble, paramInt + 1, localw.d());
        localw.f();
      }
    } while (bool2);
  }
  
  private void a(cb paramcb)
  {
    boolean bool2 = k.n;
    boolean bool1 = k.m;
    z[] arrayOfz = c(paramcb);
    double[] arrayOfDouble = new double[arrayOfz.length];
    int i = 0;
    z localz;
    e locale1;
    label126:
    do
    {
      if (i >= arrayOfz.length) {
        break;
      }
      localz = arrayOfz[i];
      if (bool1) {
        break label141;
      }
      double d1 = 0.0D;
      y localy = localz.h();
      do
      {
        if (!localy.e()) {
          break;
        }
        locale1 = (e)localy.j();
        d1 = Math.max(d1, this.y.t(locale1));
        localy.f();
        if (bool2) {
          break label128;
        }
        if (bool1) {
          break label126;
        }
      } while (!bool1);
      arrayOfDouble[i] = d1;
      if (!bool2) {
        i++;
      }
    } while (!bool1);
    label128:
    if (!bool2) {}
    label141:
    double d2 = -this.A;
    int j = 0;
    Object localObject2;
    label271:
    label273:
    do
    {
      do
      {
        if (j >= arrayOfz.length) {
          break;
        }
        d2 += this.A + arrayOfDouble[j];
        localz = arrayOfz[j];
        if (bool2) {
          break label436;
        }
        if (bool1) {
          break label427;
        }
        localObject2 = localz.h();
        do
        {
          if (!((y)localObject2).e()) {
            break;
          }
          locale1 = (e)((y)localObject2).j();
          this.y.a(locale1, this.y.m(locale1), d2 - arrayOfDouble[j] / 2.0D);
          ((y)localObject2).f();
          if (bool2) {
            break label273;
          }
          if (bool1) {
            break label271;
          }
        } while (!bool1);
        if (!bool2) {
          j++;
        }
      } while (!bool1);
    } while (bool2);
    Object localObject1;
    Object localObject3;
    label427:
    label436:
    Object localObject4;
    if (!bool2)
    {
      if (this.E == 1)
      {
        localObject1 = this.y.w();
        while (((m)localObject1).e())
        {
          localObject2 = ((m)localObject1).a();
          zc localzc = this.y.d(((d)localObject2).e());
          this.y.a((d)localObject2, new a.d.w(0.0D, localzc.d() / 2.0D));
          localObject3 = this.y.d(((d)localObject2).f());
          this.y.b((d)localObject2, new a.d.w(0.0D, -((zc)localObject3).d() / 2.0D));
          ((m)localObject1).f();
          if (bool2) {
            break label659;
          }
          if (bool1) {
            return;
          }
        }
      }
      if (bool2) {}
    }
    else if (this.E == 2)
    {
      localObject1 = this.y.v();
      label645:
      label647:
      do
      {
        do
        {
          if (!((a.c.w)localObject1).e()) {
            break label650;
          }
          localObject2 = ((a.c.w)localObject1).d();
          if (bool2) {
            break label660;
          }
          if (bool1) {
            break label659;
          }
          if (((e)localObject2).e() > 0)
          {
            double d4 = this.y.s((e)localObject2) / ((e)localObject2).e();
            double d5 = -this.y.s((e)localObject2) / 2.0D + d4 / 2.0D;
            localObject4 = ((e)localObject2).h();
            do
            {
              if (localObject4 == null) {
                break;
              }
              this.y.a((d)localObject4, new a.d.w(d5, this.y.t((e)localObject2) / 2.0D));
              this.y.b((d)localObject4, new a.d.w(0.0D, -this.y.t(((d)localObject4).f()) / 2.0D));
              d5 += d4;
              localObject4 = ((d)localObject4).i();
              if (bool2) {
                break label647;
              }
              if (bool1) {
                break label645;
              }
            } while (!bool1);
          }
        } while (bool2);
        ((a.c.w)localObject1).f();
      } while (!bool1);
    }
    label650:
    label659:
    if ((!bool2) && (this.D == 1))
    {
      label660:
      double d3 = 0.0D;
      d2 = arrayOfDouble[0];
      int k = 0;
      do
      {
        if (k >= arrayOfz.length - 1) {
          break;
        }
        localz = arrayOfz[k];
        d3 = d2 + this.A;
        localObject3 = localz.h();
        do
        {
          do
          {
            do
            {
              if (!((y)localObject3).e()) {
                break label910;
              }
              e locale2 = (e)((y)localObject3).j();
              if (bool1) {
                break;
              }
              if (locale2.e() > 1)
              {
                m localm = locale2.n();
                do
                {
                  if (!localm.e()) {
                    break;
                  }
                  localObject4 = this.y.m(localm.a());
                  ((z)localObject4).add(new a.d.w(this.y.r(localm.a()).a(), d3 - this.A / 2.5D));
                  ((z)localObject4).add(new a.d.w(this.y.s(localm.a()).a(), d3 - this.A / 2.5D));
                  this.y.b(localm.a(), (z)localObject4);
                  localm.f();
                  if (bool2) {
                    break label907;
                  }
                  if (bool1) {
                    break label905;
                  }
                } while (!bool1);
              }
            } while (bool2);
            ((y)localObject3).f();
          } while (!bool1);
          d2 = d3 + arrayOfDouble[(k + 1)];
          k++;
        } while (bool2);
      } while (!bool1);
    }
    label905:
    label907:
    label910:
    return;
  }
  
  private z[] c(cb paramcb)
  {
    boolean bool2 = k.n;
    boolean bool1 = k.m;
    z[] arrayOfz = new z[paramcb.b()];
    do
    {
      for (int i = 0; !bool1; i++)
      {
        if (i >= arrayOfz.length) {
          break;
        }
        arrayOfz[i] = new z();
      }
    } while (bool2);
    e locale = paramcb.a();
    a(paramcb.a(), 0, arrayOfz);
    return arrayOfz;
  }
  
  private void a(e parame, int paramInt, z[] paramArrayOfz)
  {
    boolean bool2 = k.n;
    boolean bool1 = k.m;
    paramArrayOfz[paramInt].b(parame);
    a.c.w localw = parame.q();
    do
    {
      while (!bool1)
      {
        if (!localw.e()) {
          break;
        }
        a(localw.d(), paramInt + 1, paramArrayOfz);
        localw.f();
      }
    } while (bool2);
  }
  
  private void d(cb paramcb)
  {
    e locale = paramcb.a();
    this.y.a(locale, 0.0D, this.y.n(locale));
    a(locale);
  }
  
  private void a(e parame)
  {
    boolean bool = k.m;
    a.c.w localw = parame.q();
    do
    {
      if (!localw.e()) {
        break;
      }
      e locale = localw.d();
      b_ localb_ = (b_)this.C.get(locale);
      this.y.a(locale, this.y.m(parame) + localb_.a, this.y.n(locale));
      a(locale);
      localw.f();
    } while (!bool);
  }
  
  private void b(e parame)
  {
    boolean bool2 = k.n;
    boolean bool1 = k.m;
    if ((bool2) || (this.x.e(parame)))
    {
      this.C.a(parame, new b_(parame));
      return;
    }
    a.c.w localw = parame.q();
    Object localObject = null;
    e locale = localw.d();
    localw.f();
    b(locale);
    b_ localb_2 = (b_)this.C.get(locale);
    b_ localb_1 = new b_(localb_2.c, localb_2.b, 0.0D);
    if (!bool2)
    {
      if (!localw.e())
      {
        localb_1.c.a(new a_(this.y.s(parame) / 2.0D, 0.0D));
        localb_1.b.a(new a_(this.y.s(parame) / 2.0D, 0.0D));
        this.C.a(parame, localb_1);
      }
    }
    else {
      return;
    }
    label295:
    a_ locala_1;
    label394:
    label571:
    do
    {
      y localy1;
      y localy2;
      double d3;
      double d4;
      a_ locala_2;
      do
      {
        if (!localw.e()) {
          break;
        }
        break label295;
        localObject = locale;
        locale = localw.d();
        localw.f();
        b(locale);
        localb_2 = (b_)this.C.get(locale);
        localy1 = localb_1.b.h();
        localy2 = localb_2.c.h();
        double d2 = 2147483647.0D;
        d3 = 0.0D;
        if (bool1) {
          break label727;
        }
        d4 = 0.0D;
        do
        {
          if (!localy1.e()) {
            break label394;
          }
          if (bool1) {
            break;
          }
          if (!localy2.e()) {
            break label394;
          }
          locala_2 = (a_)localy1.j();
          localy1.f();
          locala_1 = (a_)localy2.j();
          localy2.f();
          d4 += locala_2.c;
          d3 += locala_1.c;
          d2 = Math.min(d2, d3 - d4 - locala_2.a - locala_1.a);
        } while (!bool1);
        localb_2.a = (this.z - d2);
        d3 += localb_2.a;
        locala_1 = (a_)localb_2.b.a();
        locala_1.c = localb_2.a;
      } while (bool2);
      double d5;
      if (!bool2)
      {
        if (localy1.e())
        {
          if (bool2) {
            break label571;
          }
          if (!localy2.e())
          {
            d5 = d4 - a(localb_2.b);
            do
            {
              if (!localy1.e()) {
                break;
              }
              locala_2 = (a_)localy1.j();
              localy1.f();
              localb_2.b.b(new a_(locala_2.a, locala_2.c + d5));
              d5 = 0.0D;
              if (bool2) {
                break label697;
              }
              if (bool1) {
                break label695;
              }
            } while (!bool1);
          }
        }
        if (bool2) {
          continue;
        }
      }
      if ((bool2) || ((!localy1.e()) && (localy2.e())))
      {
        d5 = a(localb_1.c);
        d5 = d3 - d5;
        do
        {
          if (!localy2.e()) {
            break;
          }
          locala_1 = (a_)localy2.j();
          localy2.f();
          localb_1.c.b(new a_(locala_1.a, locala_1.c + d5));
          d5 = 0.0D;
          if (bool2) {
            break label697;
          }
          if (bool1) {
            break label695;
          }
        } while (!bool1);
      }
      if (bool2) {
        break label714;
      }
      localb_1.b = localb_2.b;
    } while (!bool1);
    label695:
    label697:
    this.C.a(parame, localb_1);
    label714:
    if (!bool2) {}
    label727:
    double d1 = -localb_2.a / 2.0D;
    localw = parame.q();
    if (localw.e())
    {
      locale = localw.d();
      localw.f();
      localb_2 = (b_)this.C.get(locale);
      localb_2.a += d1;
    }
    do
    {
      locala_1 = (a_)localb_2.b.a();
      locala_1.c += d1;
      locala_1 = (a_)localb_2.c.a();
      locala_1.c += d1;
      if ((!bool2) && (bool1)) {
        return;
      }
      if (!bool1) {
        break;
      }
      localb_1.c.a(new a_(this.y.s(parame) / 2.0D, 0.0D));
    } while (bool2);
    localb_1.b.a(new a_(this.y.s(parame) / 2.0D, 0.0D));
  }
  
  private double a(z paramz)
  {
    boolean bool2 = k.n;
    boolean bool1 = k.m;
    double d = 0.0D;
    y localy = paramz.h();
    do
    {
      if (!localy.e()) {
        break;
      }
      a_ locala_ = (a_)localy.j();
      if (!bool2)
      {
        if (bool1) {
          break label71;
        }
        d += locala_.c;
        localy.f();
      }
    } while (!bool1);
    label71:
    return d;
  }
  
  class b_
  {
    double a;
    z b;
    z c;
    
    b_()
    {
      this(new z(), new z(), 0.0D);
    }
    
    b_(e parame)
    {
      this();
      f.a_ locala_ = new f.a_(f.this.y.s(parame) / 2.0D, 0.0D);
      this.c.a(locala_);
      locala_ = new f.a_(f.this.y.s(parame) / 2.0D, 0.0D);
      this.b.a(locala_);
    }
    
    b_(z paramz1, z paramz2, double paramDouble)
    {
      this.c = paramz1;
      this.b = paramz2;
      this.a = paramDouble;
    }
    
    public String toString()
    {
      return "offset=" + this.a;
    }
  }
  
  static class a_
  {
    double a;
    double c;
    
    a_(double paramDouble1, double paramDouble2)
    {
      this.a = paramDouble1;
      this.c = paramDouble2;
    }
    
    public String toString()
    {
      return "{offset:" + this.c + " hw:" + this.a + "}";
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.f.n.f

 * JD-Core Version:    0.7.0.1

 */